//
//  CherryPickerDB.h
//  cherryPicker
//
//  Created by Young Soo Yun on 12. 1. 4..
//  Copyright (c) 2012 Happy. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <sqlite3.h>

@interface ReceiptDB : NSObject {
@private
    NSInteger _Id;
    NSString* _CardName;
    NSString* _Date;
    NSInteger _Price;
    NSString* _Category;
    NSInteger _Discount;
    NSString* _Delimiter;
    NSString* _Place;
}
@property (nonatomic, assign) NSInteger _Id;
@property (nonatomic, retain) NSString* _CardName;
@property (nonatomic, retain) NSString* _Date;
@property (nonatomic, assign) NSInteger _Price;
@property (nonatomic, retain) NSString* _Category;
@property (nonatomic, assign) NSInteger _Discount;
@property (nonatomic, retain) NSString* _Delimiter;
@property (nonatomic, retain) NSString* _Place;


-(id)initWithCode:(NSInteger)Id
         cardName:(NSString *)cardName
             date:(NSString *)date
            price:(NSInteger)price
         category:(NSString *)category
         discount:(NSInteger)discount
        delimiter:(NSString*)delimiter
            place:(NSString*)place;
@end

@interface CardListDB : NSObject {
	NSString* _CardName;
	NSString* _Delimiter;           // 구분자
	NSString* _Company;
    NSInteger _CardType;
    NSInteger _PayDate;
    NSInteger _UseDate;
    NSInteger _LimitPrice;
    
}

@property (nonatomic, retain) NSString* _CardName;
@property (nonatomic, retain) NSString* _Delimiter;
@property (nonatomic, retain) NSString* _Company;
@property (nonatomic, assign) NSInteger _CardType;
@property (nonatomic, assign) NSInteger _PayDate;
@property (nonatomic, assign) NSInteger _UseDate;
@property (nonatomic, assign) NSInteger _LimitPrice;

-(id)initWithCode:(NSString *)cardName
        delimiter:(NSString *)delimiter
          company:(NSString *)company
         cardType:(NSInteger)cardType
          payDate:(NSInteger)payDate
          useDate:(NSInteger)useDate
       limitPrice:(NSInteger)limitPrice;

@end

@interface CherryPickerDB : NSObject

+(BOOL)updateToCardList:(CardListDB*)cardData;
+(BOOL)insertFromCardList:(CardListDB*)cardData;
+(BOOL)deleteCardList:(NSString*)delimiter;
+(BOOL)updateToReceipt:(NSString*)delimiter
           newCardName:(NSString*)newCardName;
+(BOOL)updateToReceipt:(ReceiptDB*)receiptData;
+(BOOL)insertFromReceipt:(ReceiptDB*)receiptData;
+(BOOL)deleteReceiptWhereCard:(NSString*)delimiter;
+(BOOL)deleteReceiptWhereID:(NSInteger)ID;

+(NSArray*)selectFromCardList;
+(NSArray*)selectFromCardList:(NSString*)delimiter;
+(NSArray *)readCardListRows:(sqlite3_stmt *)stmt;
+(NSArray*)selectFromReceipt;
+(NSArray*)selectFromReceipt:(NSString*)delimiter;
+(NSArray *)readReceiptRows:(sqlite3_stmt *)stmt;
+(NSString*)selectFromReceiptForSum:(NSString *)delimiter;
+(NSString*)selectFromReceiptForSum:(NSString*)delimiter
                          dateStart:(NSString*)dateStart
                            dateEnd:(NSString*)dateEnd;

@end
